import { createApp, render} from 'vue'
import App from './App.vue'
import OverView from '@/pages/over-view/index.vue'
import MapControl from '@/pages/map-control/index.vue'
import {createRouter,createWebHistory} from 'vue-router'
import axios from 'axios'
import qs from 'qs'

declare global {//暂时使用any类型
  interface Window { __POWERED_BY_QIANKUN__: any; }
}


/**
 * 只有两个路由就不建立文件夹了
 */
const routes = [
  { path: '/', component: OverView },
  { path: '/map-Control', component: MapControl },
]
const router = createRouter({
  history: createWebHistory(),
  routes, 
})

function mountMicro(){
  createApp(App).use(router).mount('#app')
}

// 独立运行
if (!window.__POWERED_BY_QIANKUN__) {
  //登陆物业端
  axios.post(
      "/wy/user/1.0/wyLogin",
      qs.stringify({
        accountOrPhone: "13500055531",
        userPwd: "054b0ae1e67bdc0816f1ecc9cec5261e" //(wyt9021)
      })
    )
    .then(res => {
      localStorage.setItem(
        "qwt-wy-userInfo",
        JSON.stringify(res.data.data.loginSuccessUserInfo),
        );
      localStorage.setItem(
        "qwt-wy-token",res.data.data.token
      )
      mountMicro()
    });
}